<?php

/**
 *  @FileComment            [前台评论控制器]
 *  @ProjectName             项目名称：JDshop
 *  @FileName                   文件名称：CommentModel.class.php
 *  @Author                       yuerengui <596580041@qq.com>
 *  @Date                          2014-10-22 12:10:54
 *  *
 */
class CommentModel extends Model {

        public $table = 'comment';
        public $validate = array(
            array('cotag', 'nonull', '标签不能为空', 2, 3),
            array('cotext', 'nonull', '内容不能为空', 2, 3)
        );

        public function get_now_comment($uid, $gid) {
                return $this->where('user_uid=' . $uid . ' and goods_gid in(' . $gid . ')')->count();
        }

        public function get_commented_gid($uid, $gid) {
                return $this->where('user_uid=' . $uid . ' and goods_gid in(' . $gid . ')')->getField('goods_gid', TRUE);
        }

        public function add_data() {
                $data = array(
                    'cotag' => Q('post.cotag'),
                    'cotext' => Q('post.cotext'),
                    'commtime' => time(),
                    'statu' => '未审核',
                    'order_list_olid' => Q('post.order_list_olid', 0, 'intval')
                );
                return $this->add($data);
        }

        public function update_data($coid, $statu) {
                return $this->where(array('coid' => $coid))->update(array('status' => $statu));
        }

}
